home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!news
- From: jlilley@ix.netcom.com (John Lilley)
- Newsgroups: comp.lang.c++
- Subject: Re: Exporting instantiated template classes in windows DLLs
- Date: 24 Mar 1996 04:52:04 GMT
- Organization: Netcom
- Message-ID: <4j2kdk$j4l@dfw-ixnews4.ix.netcom.com>
- References: <4imc8p$3kk@btmpjg.god.bel.alcatel.be>
- NNTP-Posting-Host: den-co25-11.ix.netcom.com
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=US-ASCII
- X-NETCOM-Date: Sat Mar 23 10:52:04 PM CST 1996
- X-Newsreader: WinVN 0.99.7
-
- In article <4imc8p$3kk@btmpjg.god.bel.alcatel.be>,
- bailleuf@btmaa.bel.alcatel.be says...
- >
- >I am experimenting with DLLs in windows 95.
- >I use the MS Visual C++ 4.0 compiler.
- >How can I export an instantiated template class (if that is
- >possible ?)
-
- First, you must make sure that code is generated for all of the
- methods of the template class that you want to export, since the
- compiler won't generate them unless they are needed.
-
- It may be enough to declare a class:
-
- class EXPORT MyClassArray : public std::vector<MyClass>
- {
- private:
- void unused(); // might also be needed
- }
-
- // This might also be necessary
- MyClassArray::unused()
- {
- // call all base class template methods that you
- // want to instantiate (and export), to make
- // sure that code is generated
- }
-
- If that fails, I would try:
-
- 1) Create a source file with a single function that *calls*
- all of the template functions that you want to use,
- including any operators and constructor/destructor.
- 2) Compile the source file with your DLL.
- 3) Use a library listing utility or something similar to look
- in the obj file produced, and get the "mangled" names for
- the template class, and add EXPORT entries in the DLL .DEF file.
-
-
- Hopefully, one of these will work for you. Sorry I don't have a
- definitive answer.
-
- john lilley
-
-